<?php


class DoModel extends BaseModel
{

    var $table  = 'order';	

    var $_page_rows = 20;	
	

    function show($keyword='',$searchtype='',$status='')
    {   
	
	     empty($order)?$order = ' posttime DESC ':'';		 
         $conditions =' 1 ';
		 if($keyword!='' || ($status!='false' && $status!=''))
		{

			$type=$searchtype==1?'id':'username';
			if($keyword!='')$conditions.= ' AND '.$type.' LIKE \'%'.$keyword.'%\'';
			if($status!='false' && $status!='')$conditions.= ' AND ifpay = '.$status.' ';
		}
        $table =  $this->_prefix.'shoporderuser';
		 $info['page'] = $this->Page(array('table'=>"{$table}",'conditions' =>"{$conditions}",'url' => 'admin/?app=do&act=order'));		
		 $info['data'] = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> '*','conditions' =>"{$conditions}",'order' =>$order,'limit' =>$info['page']['sql_limit']));
  		 return $info;      
    }
    function usermoney($keyword='',$searchtype='',$status='')
    {   
	
	     empty($order)?$order = ' time DESC ':'';		 
         $conditions =' 1 ';
		 if($keyword!='' || ($status!='false' && $status!=''))
		{

			$type=$searchtype==1?'mid':'userid';
			if($keyword!='')$conditions.= ' AND '.$type.' LIKE \'%'.$keyword.'%\'';
			if($status!='false' && $status!='')$conditions.= ' AND type = '.$status.' ';
		}
        $table =  $this->_prefix.'usermoney';
		 $info['page'] = $this->Page(array('table'=>"{$table}",'conditions' =>"{$conditions}",'url' => 'admin/?app=do&act=usermoney'));		
		 $info['data'] = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> '*','conditions' =>"{$conditions}",'order' =>$order,'limit' =>$info['page']['sql_limit']));
  		 return $info;      
    }

	function ordercontent($id)
	{
		 $info = $this->S_Sql_Exe(array('table'=>$this->_prefix.'shoporderuser','fields' =>'*','conditions' =>" id='{$id}'",'return' =>'one'));		     
		 return $info;
	}
	
    function del($id ='')
    {      
		return $this->D_Sql_Exe(array ('table'=>$this->_prefix.'shoporderuser','conditions' =>"id = '{$id}' "));
        
    }
	function moneyadd($money,$uid)
	{
		$sql="update ".$this->_prefix."users set money = money + $money where user_id = ".$uid;
		return $query = $this->db->query($sql); 
	}
	function moneylog($ary){

		return $this->IU_Sql_Exe(array ('table'=>$this->_prefix.'usermoney','data' => $ary, 'mode' => 'INSERT'));
	}	
	function moneypay($money,$uid,$shopmoney=0)
	{
			
		$sql="update ".$this->_prefix."users set money = money - $money,totalpay = totalpay + $money,shopmoney = shopmoney + $shopmoney where user_id = ".$uid;
		return $query = $this->db->query($sql); 

		
	}

}








?>